String clazzTpl({package}) => """
import 'dart:ui';
import 'app.dart';
import 'dart:async';
import 'store/redux/redux.dart';
import 'utils/sys_error_util.dart';
import 'store/redux/reducers.dart';
import 'store/redux/redux_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'store/app_config/app_config_state.dart';
import 'package:$package/store/theme/theme_state.dart';

void main() {
  FlutterError.onError = SysErrorUtil.onError;
  ErrorWidget.builder = SysErrorUtil.builder;

  runZonedGuarded<Future<void>>(
    () async {
      WidgetsFlutterBinding.ensureInitialized();

      await Future.wait<dynamic>([
        AppAndDevice.loadAppPackageInfo(),
      ]);
      final engine = PersistorEngine(
          '${package}_store_v\${AppAndDevice.appVersion}_\${AppAndDevice.appBuildNumber}');

      final store = Store<ReduxState>(
        appReducer,
        middleware: [engine.persistor.createMiddleware(), ...userMiddleware],
        initialState: await engine.initialState,
      );

      if (store.state.themeState!.brightness == Brightness.light) {
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light
            .copyWith(systemNavigationBarColor: Colors.white));
      } else {
        SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light
            .copyWith(systemNavigationBarColor: const Color(0xFF1A1A1A)));
      }

      SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);
      runApp(App(store: store, route: window.defaultRouteName));
    },
    SysErrorUtil.writeErrorLog,
    zoneSpecification: ZoneSpecification(
      print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
        if (kDebugMode) parent.print(zone, line);
      },
      handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone,
          Object error, StackTrace stackTrace) {
        SysErrorUtil.writeErrorLog(error, stackTrace);
      },
    ),
  );
}
""";
